<?php

namespace App\Admin\Requests;

use App\Admin\Models\SystemModel;
use App\Admin\Models\WorshipPpt;
use App\Admin\Rules\LectionRules;
use Illuminate\Support\Arr;

class WorshipPptRequest extends FormRequest
{
    public function rules(SystemModel $systemModel, WorshipPpt $worshipPpt)
    {
        $rules = $systemModel->formValidationRules($worshipPpt->getTable());
        $rules['response_bible'] = [
            $rules['response_bible'], new LectionRules()
        ];
        $rules['preach_lection'] = [
            $rules['preach_lection'], new LectionRules()
        ];
        if ($this->isMethod('put')) {
            $rules = Arr::only($rules, $this->keys());
        }
        return $rules;
    }

    public function messages()
    {
        return [];
    }

    public function attributes()
    {
        $systemModel = new SystemModel();
        $worshipPpt = new WorshipPpt();
        return $systemModel->fieldAttributes($worshipPpt->getTable());
    }
}
